home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / lists / src / findname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.8 KB  |  85 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: findname.c 1.1 1995/11/05 22:49:09 digulla Exp digulla $
  4.     $Log: findname.c $
  5.  * Revision 1.1  1995/11/05  22:49:09  digulla
  6.  * Initial revision
  7.  *
  8.     Desc:
  9.     Lang: english
  10. */
  11. #define AROS_ALMOST_COMPATIBLE
  12. #include "exec_intern.h"
  13. #include <clib/aros_protos.h>
  14.  
  15. /*****************************************************************************
  16.  
  17.     NAME */
  18.     #include <exec/lists.h>
  19.     #include <clib/exec_protos.h>
  20.  
  21.     __AROS_LH2I(struct Node *, FindName,
  22.  
  23. /*  SYNOPSIS */
  24.     __AROS_LA(struct List *, list, A0),
  25.     __AROS_LA(UBYTE       *, name, A1),
  26.  
  27. /*  LOCATION */
  28.     struct SysBase *, SysBase, 46, Exec)
  29.  
  30. /*  FUNCTION
  31.     Look for a node with a certain name in a list.
  32.  
  33.     INPUTS
  34.     list - Search this list.
  35.     name - This is the name to look for.
  36.  
  37.     RESULT
  38.  
  39.     NOTES
  40.     The search is case-sensitive, so "Hello" will not find a node
  41.     named "hello".
  42.  
  43.     The list must contain complete Nodes and no MinNodes.
  44.  
  45.     EXAMPLE
  46.     struct List * list;
  47.     struct Node * node;
  48.  
  49.     // Look for a node with the name "Hello"
  50.     node = FindName (list, "Hello");
  51.  
  52.     BUGS
  53.  
  54.     SEE ALSO
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.     26-08-95    digulla created after EXEC-Routine
  60.     26-10-95    digulla adjusted to new calling scheme
  61.  
  62. ******************************************************************************/
  63. {
  64.     struct Node * node;
  65.  
  66.     assert (list);
  67.     assert (name);
  68.  
  69.     /* Look through the list */
  70.     for (node=GetHead(list); node; node=GetSucc(node))
  71.     {
  72.     /* check the node. If we found it, stop */
  73.     if (!STRCMP (node->ln_Name, name))
  74.         break;
  75.     }
  76.  
  77.     /*
  78.     If we found a node, this will contain the pointer to it. If we
  79.     didn't, this will be NULL (either because the list was
  80.     empty or because we tried all nodes in the list)
  81.     */
  82.     return node;
  83. } /* FindName */
  84.  
  85.